package controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import common.R;
import entity.Book;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import service.BookService;

@RestController
@RequestMapping("/book")
@PostMapping("/buy")
public class buycontroller {
    @Autowired
    private BookService bookService;

    private R<Book>Buy(@RequestBody Book book){
     String name=book.getName();
        LambdaQueryWrapper<Book> ans=new LambdaQueryWrapper<>();
        ans.eq(Book::getName,name);
        Book book1 =bookService.getOne(ans);
        if(book1!=null){
            return R.success(book1);
        }
        return R.error("错误");
    };


}
